#include "Window.hpp"

namespace rgui
{

Window::Window(const rgui::vec2f &position, const rgui::vec2f &size, const std::wstring &title) : RenderObject(),
	mRectangle(position, size),
	mTitle(title, rgui::vec2f(position.x + size.x * 0.5f, 0.0f))
{
	mTitle.setAlignment(rgui::Text::AlignmentX::CENTER, rgui::Text::AlignmentY::TOP);
}

const rgui::vec2f& Window::getPosition()
{
	return mRectangle.getPosition();
}

const rgui::vec2f& Window::getSize()
{
	return mRectangle.getSize();
}

const std::wstring& Window::getTitle()
{
	return mTitle.getString();
}

void Window::setPosition(const rgui::vec2f &position)
{
	mRectangle.setPosition(position);
}

void Window::setSize(const rgui::vec2f &size)
{
	mRectangle.setSize(size);
}

void Window::setTitle(const std::wstring &title)
{
	mTitle.setString(title);
}

bool Window::contains(const rgui::vec2f &position)
{
	const rgui::vec2f &pos = mRectangle.getPosition();
	const rgui::vec2f &size = mRectangle.getSize();
	return position.x >= pos.x && position.x <= pos.x + size.width
		&& position.y >= pos.y && position.y <= pos.y + size.height;
}

}